package ru.st.selenium.pages;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class AddFilmPage  extends InternalPage {
	
	public AddFilmPage(PageManager pages) {
		super(pages);
	}
	
	  @FindBy(name = "name")
	  private WebElement nameField;
		
	  @FindBy(name = "year")
	  private WebElement yearField;
	  
	  @FindBy(id = "submit")
	  private WebElement submitButton;
	  
	  @FindBy(xpath = "//*[@id='movie']")
	  private WebElement addPage;
	  
	  public AddFilmPage setNameField(String text) {
		  nameField.sendKeys(text);
		    return this;
		  }
	  
	  public AddFilmPage setYearField(String text) {
		  yearField.sendKeys(text);
		    return this;
		  }
	  
	  public AddFilmPage clickSubmitButton() {
		  submitButton.click();
		    return this;
		  }
	  
	  public boolean isDescriptionFilm(String text) {
	  return addPage.getText().contains(text);
	  }
	  
	  public boolean IsErrorVisible(){
			 return driver.getPageSource().contains("This field is required");
		 }
}
